

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QObject>
#include<QGraphicsPixmapItem>
#include<QString>
#include<QGraphicsSceneMouseEvent>
#include<QGraphicsScene>
#include<QTimer>
#include<QCloseEvent>

/*QMediaPlayer *player=new QMediaPlayer;
player->(QUrl::fromeLocalFile())
    player->setVolume(50);
connect (ui->actionPlay,&QAction::triggered,[=](){
    player->play();
});
connect(ui->actionStop,&QAction::triggered,[=](){
    player->stop();
});
*/
class Handler : public QObject
{
    Q_OBJECT


private:
    explicit Handler(QObject *parent = nullptr);

public:
    static Handler * getInstance();
    void addScore();
    void setScore();
    void subtractScore();
    void setTime();
    void stopTime();

signals:
    void beatMouse();
    void beatnoneMouse();
    void returntozero();
    void resettime();
    void stoptime();

public slots:
private:
    static Handler * hand;
};
class MyItem : public QGraphicsPixmapItem
{
public:
    MyItem();
    void setPic(QString path);
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
    void setMouse(bool mouse);
    bool isMouse();
    void setStart(bool start);
    bool isStart();

private:
    bool mouse;
    bool start;
};
class MyScene : public QGraphicsScene
{
    Q_OBJECT
public:
    explicit MyScene(QObject *parent = nullptr);

signals:

public slots:
    void showMouse();
    void startGame();
    void endGame();

private:
    MyItem *item[16];
    QTimer *ptimer;
};
#endif // MAINWINDOW_H

